<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>课程信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript" src="/static/jquery/jquery.form.js"></script>
	<script type="text/javascript">
        function uploadPic() {
            var options={
                url:"/upload/uploadPic",
                type:"post",
                dataType:"text",
                success:function(data){
                    // 图片回显
                    $("#imgurl").attr("src",data);
                    // 图片的url地址保存数据库
                    $("#imageUrl").val(data);

                }
            }
            $("#inputForm").ajaxSubmit(options);
        }
        $(document).ready(function() {

            $("#value").focus();
            $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
	</script>
	<script type="text/javascript">
        function ccdian(){
            // 是否限制选择，如果限制，设置为disabled
            if ("" == "disabled"){
                return true;
            }
            // 正常打开
            var subjec = $("#subject").val();
            top.$.jBox.open("iframe:/admin/tag/treeselect?url="+
                encodeURIComponent("/business/knowledge/all2?subject="+subjec)+"&module=&checked=true&extId=&selectIds="
                +$("#knowledgersidId").val(), "选择知识点儿", 300, 420, {
                buttons:{"确定":"ok", "关闭":true}, submit:function(v, h, f){
                    if (v=="ok"){
                        var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents();
                        var ids = [], names = [], nodes = [];
                        if ("true" == "true"){
                            nodes = tree.getCheckedNodes(true);
                        }else{
                            nodes = tree.getSelectedNodes();
                        }
                        for(var i=0; i<nodes.length; i++) {//
                            if (nodes[i].isParent){
                                continue; // 如果为复选框选择，则过滤掉父节点
                            }//
                            ids.push(nodes[i].id);
                            names.push(nodes[i].name);//
                        }
                        $("#knowledgersidId").val(ids);
                        $("#knowledgersidName").val(names);
                    }//
                }, loaded:function(h){
                    $(".jbox-content", top.document).css("overflow-y","hidden");
                }
            });
        }
	</script>
</head>
<body>
<ul class="nav nav-tabs">
	<li><a href="${ctx}/business/course">课程信息列表</a></li>
	<li class="active"><a href="${ctx}/business/course?id=${course.id}">课程信息<shiro:hasPermission name="business:course:edit">${not empty course.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="business:course:edit">查看</shiro:lacksPermission></a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="course" action="${ctx}/business/course/save" method="post" class="form-horizontal">
	<form:hidden path="id"/>
	<form:hidden path="cover" id="imageUrl" name="cover" class="required"/>
	<tags:message content="${message}"/>
	<div class="control-group">
		<label class="control-label">课程名称:</label>
		<div class="controls">
			<form:input path="title" name="title" htmlEscape="false" maxlength="50" class="required"/>
		</div>
	</div>

		<div class="control-group">
			<label class="control-label">图上进行上传:</label>
			<div class="controls">
				<input type="file" name="pic" accept="image/gif, image/jpeg,image/png" onchange="uploadPic()"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">课程封面:</label>
			<div class="controls">
			<img id="imgurl" src="${course.cover}?x-oss-process=style/default">
			</div>
		</div>
	  <div class="control-group">
      	<label class="control-label">是否免费:</label>
      	<div class="controls">
			<form:select path="free" name="free">
				<form:options items="${dic:getBusDictList('course_if_free')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
			</form:select>
      	</div>
      </div>
	<div class="control-group">
		<label class="control-label">课程简介:</label>
		<div class="controls">
			<form:textarea path="abstractContent" htmlEscape="false" class="span6 required"
						   placeholder="请填写课程简介！"/>
		</div>
	</div>
	<div class="control-group">
		<label class="control-label">课程大纲:</label>
		<div class="controls">
			<form:textarea path="outline" htmlEscape="false" class="span6 required"
						   placeholder="请填写课程大纲！"/>
			<tags:ckeditor replace="outline" uploadPath="/upload/file"/>
		</div>
	</div>
	  <div class="control-group">
      	<label class="control-label">课程介绍:</label>
      	<div class="controls">
			<form:textarea path="introduction" htmlEscape="false" class="span6 required"
						   placeholder="请填写课程介绍！"/>
			<tags:ckeditor replace="introduction" uploadPath="/upload/file"/>
			<span class="help-inline"><font color="red">*</font> </span>
      	</div>
      </div>
	  <div class="control-group">
      	<label class="control-label">课程原价:</label>
      	<div class="controls">
      		<form:input path="originalPrice" name="originalPrice" htmlEscape="false" maxlength="50" class="required"/>
      	</div>
      </div>
	  <div class="control-group">
      	<label class="control-label">课程现价:</label>
      	<div class="controls">
      		<form:input path="presentPrice" name="presentPrice" htmlEscape="false" maxlength="50" class="required"/>
      	</div>
      </div>
	  <div class="control-group">
      	<label class="control-label">课程序号:</label>
      	<div class="controls">
      		<form:input path="seq" name="seq" htmlEscape="false" maxlength="50" class="required"/>
      	</div>
      </div>
	  <div class="control-group">
      	<label class="control-label">主讲老师:</label>
      <div class="controls">
		  <tags:pageselect id="teacher" name="teacher.id"
			 value="${course.teacher.id}" labelName="teacher.name"
				labelValue="${course.teacher.name}"
			title="讲师" url="/business/teacher/select2" width="800" height="540"
			cssClass="required"/>
		</div>
      </div>
	<div class="control-group">
		<label class="control-label">备注:</label>
		<div class="controls">
			<form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="input-xlarge"/>
		</div>
	</div>
	<div class="form-actions">
		<shiro:hasPermission name="business:course:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
		<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
	</div>
</form:form>
</body>
</html>